#!/bin/sh
CWD=`pwd`
PKG=/tmp/dracosrc.$$
VERSION=0.3.1

rm -rf $PKG
mkdir -p $PKG

mkdir -p $PKG/dracosrc-$VERSION

cp -a $CWD/* $PKG/dracosrc-$VERSION/ || exit 1

( cd $PKG;
  for svn in $(find . -type d -name ".svn" -maxdepth 100) ; do
    rm -rf $svn
  done
  for work in $(find . -type d -name "work" -maxdepth 100) ; do
    rm -rf $work
  done  
  for distfiles in $(find . -type d -name "distfiles" -maxdepth 100) ; do
    rm -rf $distfiles
  done
  for packages in $(find . -type d -name "packages" -maxdepth 100) ; do
    rm -rf $packages
  done
  for logs in $(find . -type d -name "logs" -maxdepth 100) ; do
    rm -rf $logs
  done
  find . -type f -name "*~" -exec rm {} \;
)
mkdir -p $PKG/dracosrc-$VERSION/{distfiles,packages,logs}

chmod 644 -R $PKG
chown root:root -R $PKG
( cd $PKG ; tar cvvjf dracosrc-$VERSION.tar.bz2 dracosrc-$VERSION )
mv $PKG/dracosrc-$VERSION.tar.bz2 $CWD/
rm -rf $PKG
